package com.shenmazong.serveredustudent.controller;

import com.shenmazong.serveredustudent.pojo.TbClazz;
import com.shenmazong.serveredustudent.pojo.TbClazzTeacher;
import com.shenmazong.serveredustudent.pojo.TbCollage;
import com.shenmazong.serveredustudent.pojo.TbStage;
import com.shenmazong.serveredustudent.service.TbClazzService;
import com.shenmazong.serveredustudent.service.TbClazzTeacherService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.ListParamVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 满天星斗
 * @version 1.0
 * @description: TODO
 * @date 2021/9/24 12:30
 */
@RestController
@RequestMapping("/clazz")
@Api(tags = "班级管理接口")
public class ClazzController {

    @Autowired
    private TbClazzService clazzService;

    @Autowired
    private TbClazzTeacherService clazzTeacherService;

    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description getClazzsByStageId
     * @params [stageId]
     * @author S1763
     * @date 2021/9/21 19:46
     */
    //查询阶段下所有的班级
    @PostMapping("/getClazzsByStageId")
    public ResultResponse getClazzsByStageId(@RequestBody TbStage stageId) {
        return clazzService.getClazzsByStageId(stageId.getStageId());
    }

    /**
     * @description createClazz
     * @params [clazz]
     * @return com.shenmazong.utils.ResultResponse
     * @author S1763
     * @date 2021/9/22 9:21
     */
    //新建班级
    @PostMapping("/createClazz")
    public ResultResponse createClazz(@RequestBody TbClazz clazz){
        return clazzService.createClazz(clazz);
    }

    /**
     * @description updateClazz
     * @params [clazz]
     * @return com.shenmazong.utils.ResultResponse
     * @author S1763
     * @date 2021/9/22 13:41
     */
    //修改班级
    @PostMapping("/updateClazz")
    public ResultResponse updateClazz(@RequestBody TbClazz clazz){
        return clazzService.updateClazz(clazz);
    }


    /**
     * @description deleteClazz
     * @params [clazzId]
     * @return com.shenmazong.utils.ResultResponse
     * @author S1763
     * @date 2021/9/22 13:41
     */
    //删除班级
    @PostMapping("/deleteClazz")
    public ResultResponse deleteClazz(@RequestBody TbClazz clazz){
        return clazzService.deleteClazz(clazz.getClazzId());
    }

    /**
     * @description getAllClazz
     * @params
     * @return com.shenmazong.utils.ResultResponse
     * @author S1763
     * @date 2021/9/22 13:41
     */
    @PostMapping("/getAllClazz")
    public ResultResponse getAllClazz(@RequestBody ListParamVo listParamVo){
        return clazzService.getAllClazz(listParamVo);
    }

    @PostMapping("/saveTeacherToClazz")
    public ResultResponse saveTeacherToClazz(@RequestBody TbClazzTeacher tbTeacher){
        return clazzTeacherService.saveTeacherToClazz(tbTeacher);
    }

    @PostMapping("/getClazzListVoByCollageId")
    public ResultResponse getClazzListVoByCollageId(@RequestBody TbCollage collage){
        return clazzTeacherService.getClazzListVoByCollageId(collage);
    }


}
